with open('sum_sql.sql', 'r', encoding='utf-8') as f:
    lines = f.readlines()
    results = []
    for line in lines:
        line = line.replace('\n', '')
        if line.find('sum(') > 0:
            # print(line)
            index = line.find('_')
            pre = line[0: index + 1];
            end = line[index + 1: len(line)]

            khindex = end.find(')')

            number = end[0:khindex]

            # print(pre)
            # print(end)
            # print(number)

            result = pre + number + ') as f_' + number + ','
            print(result)
